package main

import (
	"fmt"
	"sync"
)

func main() {
	wg := &sync.WaitGroup{}
	ch1 := make(chan int)
	ch2 := make(chan int)
	quit := make(chan struct{})
	wg.Add(1)
	go func ()  {
		defer wg.Done()
		for{
		select{
		case data := <-ch1:
			fmt.Println(fmt.Sprintf("process 1 print :%d",data))
		case data := <-ch2:
			fmt.Println(fmt.Sprintf("process 2 print :%d",data))
		case <-quit:
			return
		}		
		}
	}()
	for i := 0; i < 100; i++ {
		if i%2 == 0 {
			ch1 <- i
		}else{
			ch2 <-i
		}
	}
	quit <- struct{}{}
	
	wg.Wait()
}
